package crudfx.util;
import crudfx.interop.*;
import crudfx.field.*;
import crudfx.navigation.*;
import crudfx.util.*;
import crudfx.util.resources.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public var instance:DefaultComponents=DefaultComponents{};
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class DefaultComponents{
    public var stringFieldPopUp:PopUp=null;
    public function showPopup(stringField:StringField,x:Integer,y:Integer):Void{
        if(stringFieldPopUp==null){
            stringFieldPopUp=PopUp{
                items:[
                    MenuLink{
                        text:"Copy selected"
                        action:stringField.copy
                        icon:ResourceLoader.imageIcon("copy.png")
                        }
                    ,MenuLink{
                        text:"Cut selected"
                        action:stringField.cut
                        icon:ResourceLoader.imageIcon("cut.png")
                        }
                    ,MenuPad{}
                    ,MenuLink{
                        text:"Paste"
                        action:stringField.paste
                        icon:ResourceLoader.imageIcon("paste.png")
                        }
                    ,MenuPad{}
                    ,MenuLink{ text:"Select all" action:stringField.selectAll }
                    ]
                };
            }
        stringFieldPopUp.show(stringField,x,y);
        }
    init{

        }
    }
